<template>
	<view class="conversationCell" @click='click'>
		<view class="left">
			<image class="cover" :src="item.conversationType=='system'?'/static/login/logo.png':item.userInfo.avatarUrl" mode="aspectFill"></image>
			<view class="dot" v-if="item.onlineStatus == 'Y'"><view class="subDot"></view></view>
		</view>
		<view class="content">
			<view class="top">
				<view class="nickname uni-title-h5 limitLineNumOfOne">{{item.conversationType=='system'?'系统消息': getNickname(item.userInfo.nickname) }}</view> 
				<view class="time">{{$time.dateFormat('yyyy-mm-dd HH:MM', item.lastMessage.createTime)}}</view>
			</view>
			<view class="footer">
				<view class="desc limitLineNumOfOne">{{item.lastMessage.content}}</view>
				<jc-badge :count='item.unreadCount'></jc-badge>
			</view>
		</view>
	</view>
</template>

<script>
	import jcBadge from '@/components/jc-badge/jc-badge.vue'
	import {uploadApi, upload_baseUrl} from '@/api/baseUrl.js'
	export default {
		components:{jcBadge},
		props:{
			item: {
				type: Object,
				default: {}
			}
		},
		data() {
			return {
				upload_baseUrl:upload_baseUrl
			};
		},
		methods:{
			click(){
				this.$emit('click')
			},
			formatTime(time){
				return this.$time.formatTime(time)
			},
			getNickname(nickname){
				return decodeURIComponent(nickname)
			},
		},
	}
</script>

<style lang="scss" scoped>
	$coverWH : 100rpx;
	.conversationCell{
		// width: 710rpx;
		background-color: #FFFFFF;
		border-bottom: 1px solid $st-bg-color;
		padding: 20rpx;
		display: flex;
		flex-direction: row;
		.left{
			position: relative;
			.cover{
				width: $coverWH;
				height: $coverWH;
				border-radius: 16rpx;
				margin-right: 20rpx;
			}
			.dot{
				width: 28rpx;
				height: 28rpx;
				border-radius: 14rpx;
				background-color: #FFFFFF;
				position: absolute;
				left: calc(120rpx - 28rpx);
				top: calc(120rpx - 28rpx);
				display: flex;
				align-items: center;
				justify-content: center;
				.subDot{
					width: 20rpx;
					height: 20rpx;
					border-radius: 10rpx;
					background-color: $uni-color-success;
				}
			}
		}
		.content{
			display: flex;
			flex-direction: column;
			width: 590rpx;
			.top{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				.time{
					flex-shrink: 0;
					color: #999999;
					font-size: 22rpx;
				}
			}
			.footer{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				margin-top: 16rpx;
				.desc{
					color: #999999;
					font-size: 26rpx;
				}
			}
		}
	}
</style>
